package io.qifan.desktop.server.controller.http;

import io.qifan.desktop.common.model.R;
import io.qifan.desktop.server.application.DeviceApplication;
import io.qifan.desktop.api.device.DeviceDto;
import io.qifan.desktop.server.domain.device.mapper.DeviceMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("device")
@RequiredArgsConstructor
public class DeviceController {
    private final DeviceApplication deviceApplication;

    @GetMapping("findByName")
    public R<DeviceDto> findUserDevice(@RequestParam String deviceName) {
        return R.ok(DeviceMapper.INSTANCE.deviceToDeviceDto(deviceApplication.findByDeviceName(deviceName)));
    }
}
